{
GtkMultiSelection *self;
- g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
+ g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
self = g_object_new (GTK_TYPE_MULTI_SELECTION,
"model", model,
{
GtkNoSelection *self;
- g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
+ g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
self = g_object_new (GTK_TYPE_NO_SELECTION,
"model", model,
{
GtkSingleSelection *self;
- g_return_val_if_fail (G_IS_LIST_MODEL (model), NULL);
+ g_return_val_if_fail (model == NULL || G_IS_LIST_MODEL (model), NULL);
self = g_object_new (GTK_TYPE_SINGLE_SELECTION,
"model", model,
g_object_unref (selection);
}
+static void
+test_create_empty (void)
+{
+ GtkMultiSelection *selection;
+
+ selection = gtk_multi_selection_new (NULL);
+ g_assert_cmpint (g_list_model_get_n_items (G_LIST_MODEL (selection)), ==, 0);
+
+ g_object_unref (selection);
+}
+
static void
test_changes (void)
{
selection_quark = g_quark_from_static_string ("Mana mana, badibidibi");
g_test_add_func ("/multiselection/create", test_create);
+ g_test_add_func ("/multiselection/create-empty", test_create_empty);
#if GLIB_CHECK_VERSION (2, 58, 0) /* g_list_store_splice() is broken before 2.58 */
g_test_add_func ("/multiselection/changes", test_changes);
#endif
g_object_unref (selection);
}
+static void
+test_create_empty (void)
+{
+ GtkSingleSelection *selection;
+
+ selection = gtk_single_selection_new (NULL);
+ g_assert_cmpint (g_list_model_get_n_items (G_LIST_MODEL (selection)), ==, 0);
+
+ g_object_unref (selection);
+}
+
static void
test_changes (void)
{
selection_quark = g_quark_from_static_string ("Mana mana, badibidibi");
g_test_add_func ("/singleselection/create", test_create);
+ g_test_add_func ("/singleselection/create-empty", test_create_empty);
g_test_add_func ("/singleselection/autoselect", test_autoselect);
g_test_add_func ("/singleselection/autoselect-toggle", test_autoselect_toggle);
g_test_add_func ("/singleselection/selection", test_selection);